package com.linxz.framework.base;

import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import androidx.annotation.NonNull;

import com.linxz.framework.base.presenter.BasePresenter;
import com.linxz.framework.ui.loader.LoadingView;

/**
 * @author Linxz
 * 创建日期：2019年02月20日 20:50
 * version：1.0.0
 * 描述：
 */
public abstract class BaseMVPFragment<P extends BasePresenter> extends BaseFragment {
    protected String TAG=getClass().getName();
    public P mvpPresenter;

    protected abstract P createPresenter();

    @Override
    public View onCreateView(@NonNull LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
        mvpPresenter = createPresenter();
        return super.onCreateView(inflater, container, savedInstanceState);
    }

    @Override
    public void onDestroy() {
        super.onDestroy();
        if (mvpPresenter != null) {
            mvpPresenter.detachView();
        }
        super.onDestroy();
    }

    public void showLoading(String msg){
        LoadingView.getInstance().showLoading(activity,msg);
    }

    public void hideLoading(){
        LoadingView.getInstance().hideLoading();
    }

}

